//
//  DHSubtitleView.m
//  DHKuaiYi
//
//  Created by 韩旭 on 16/11/13.
//  Copyright © 2016年 30-陈辉华. All rights reserved.
//

#import "DHSubtitleView.h"
#import "Masonry.h"
@implementation DHSubtitleView

- (void)xhhSetupSubviews{
    
    [super xhhSetupSubviews];
    [self setupUI];
    [self startAnimationIfNeeded];
}
-(void)setupUI{
    UIImageView *imgSub = [[UIImageView alloc]init];
    self.imgSub = imgSub;
    imgSub.image=[UIImage imageNamed:@"ic_fack_keyboard_btn_send.jpg"];
    CGSize imgSize = CGSizeMake(6, 20);
    [self addSubview:imgSub];

    UILabel *labelLeft = [[UILabel alloc]init];
    self.labelLeft= labelLeft;
       labelLeft.text = @"名医通";
    labelLeft.font=[UIFont systemFontOfSize:30];
    labelLeft.textColor = [UIColor XHH_colorWithHex:0x000000];
    [self addSubview:labelLeft];
    
    UIScrollView *scrView = [[UIScrollView alloc]init];
    [self addSubview:scrView];
    
    UILabel *labelRight=[[UILabel alloc]init];
    self.labelRight =labelRight;
    self.labelRight.textAlignment = NSTextAlignmentRight;
    [scrView addSubview:labelRight];

    //自动布局
    [imgSub mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(15);
        make.left.mas_equalTo(self).offset(12);
        make.size.mas_equalTo(imgSize);
    }];
    
    [labelLeft mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self).offset(10);
        make.left.mas_equalTo(imgSub).offset(15);
    }];
    [scrView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.bottom.mas_equalTo(self);
        make.left.mas_equalTo(labelLeft.mas_right);

    }];

    [labelRight mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.top.bottom.mas_equalTo(scrView);
        make.centerY.mas_equalTo(self);
    }];

}

-(void)startAnimationIfNeeded{
    //取消、停止所有的动画 @"  组长:陈汉茂 陈辉华 组员: 刘鹏飞 郑育彬 韩旭"
    self.labelRight.text= @"  组长:陈汉茂 陈辉华 组员: 刘鹏飞 郑育彬 韩旭";
    self.labelRight.textColor = [UIColor XHH_colorWithHex:0x2FC5C5];
        [UIView animateWithDuration:10.0
                              delay:0
                            options:UIViewAnimationOptionRepeat //动画重复的主开关

                         animations:^{
                             self.labelRight.transform = CGAffineTransformMakeTranslation(-360, 0);
                         }
                         completion:^(BOOL finished) {
                             
                         }
         ];
    

}
@end
